<template>
  <el-row type="flex" justify="center">
    <el-col :span="12">
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="组织代码:" prop="orgCode">
          <el-input v-model="form.orgCode" placeholder="组织代码"></el-input>
        </el-form-item>
        <el-form-item label="组织名称:" prop="orgName">
          <el-input v-model="form.orgName" placeholder="组织名称"></el-input>
        </el-form-item>
        <el-form-item label="地址信息:" prop="orgSite">
          <el-input class="desc" type="textarea" v-model="form.orgSite" rows="3" placeholder="地址信息......"></el-input>
        </el-form-item>
        <el-form-item label="组织简介:" prop="des">
          <el-input class="desc" type="textarea" v-model="form.des" rows="3" placeholder="简介......"></el-input>
        </el-form-item>
        <el-form-item style="text-align: center">
          <el-button type="primary" @click="onSubmit">提交</el-button>
          <el-button type="danger" @click="cancel">取消</el-button>
        </el-form-item>
      </el-form>
    </el-col>
  </el-row>
</template>

<script>
import {orgPublic} from "@/api/operations-center/org";

export default {
  name: "OrganSaveEditAuto",
  mixins: [orgPublic],
  props: {
    formData: {
      type: Object,
      required: false
    }
  },
  data() {
    return {
      antiShake: null
    }
  },
  methods: {
    onSubmit() {
      if (this.antiShake) {
        clearTimeout(this.antiShake);
      }
      this.antiShake = setTimeout(() => {
        this.$refs['form'].validate((valid) => {
          if (valid) {
            this.$emit("onSubmit", this.form)
          } else {
            return false;
          }
        });
      }, 1000);
    }
  },
  watch: {
    formData(n) {
      this.form = {
        ...n
      }
    }
  }
}
</script>

<style scoped>

</style>